package com.example.iot.activity;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import com.example.iot.R;
import com.example.iot.utils.HttpService;

import java.io.IOException;

public class HttpServerActivity extends AppCompatActivity {
    HttpService http = new HttpService(9988);

    //安卓创建事件
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_httpserver);
        System.out.println("服务启动中");
        try {
            http.start();
            System.out.println("服务启动完成");
        } catch (IOException e) {
            e.printStackTrace();
            System.out.println("服务启动错误");
        }
    }

    //安卓销毁事件
    @Override
    protected void onDestroy() {
        super.onDestroy();
        http.stop();
    }
}

